﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Web;

namespace DuelQuizzServer
{
    public class Utils
    {
        public static IList<T> shuffle<T>(IList<T> list)
        {
            Random rng = new Random();
            int n = list.Count;
            while (n > 1)
            {
                n--;
                int k = rng.Next(n + 1);
                T value = list[k];
                list[k] = list[n];
                list[n] = value;
            }

            return list;
        }

        public static ICollection<T> shuffle<T>(ICollection<T> list)
        {
            IList<T> new_list = new List<T>();
            foreach (T tmp in list) 
                new_list.Add(tmp);

            return shuffle(new_list);
        }

        public static Object getEntityFromProxy(Object proxy)
        {
            var obj = ObjectContext.GetObjectType(proxy.GetType());
           
            return obj;
        }
    }
}